<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<Ditto.Models.Item>" MasterPageFile="~/Views/Shared/Site.Master"  %>

<asp:Content ID="Title" ContentPlaceHolderID="TitleContent" runat="server">
    Post an Item
</asp:Content>

<asp:Content ID="Create" ContentPlaceHolderID="MainContent" runat="server">
    <script src="/Scripts/MicrosoftAjax.js" type="text/javascript"></script>
    <script src="/Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
    <script src="/Scripts/MicrosoftMvcValidation.js" type="text/javascript"></script>
    <h2>Post an Item</h2>

     <% Html.EnableClientValidation(); %>
    <%: Html.ValidationSummary("Please correct the errors and try again.") %>
    <% using (Html.BeginForm())
       { %>
    <fieldset style="border-style:none">
<%--        <div id="itemDiv">
            <%:Html.EditorForModel() %>
            <p>


                <input type="submit" value="Save" class="button" />
            </p>
        </div>
--%>

        
<%-- separate OPTIONAL and REQUIRED.. allow for people to enter items quickly! even better add jquery popup form --%>
        <div id="itemDiv">

        <div class="widget">
            <p>
                <%: Html.LabelFor(m => m.Title)%>
                <%: Html.EditorFor(m => m.Title)%>
            </p>

            <p>
                <%: Html.LabelFor(m => m.Description)%>
                <%: Html.TextAreaFor(m => m.Description, 6, 35, new { style = "width:231px;height:auto;padding:5px;margin:0px 0px 0px 0px;overflow:auto;display:block;float:left" })%>
            </p>
            <p>
                <%: Html.LabelFor(m => m.Address)%>
                <%: Html.EditorFor(m => m.Address)%>
            </p>

            <p>
                <%: Html.LabelFor(m => m.Tags)%>
                <%: Html.EditorFor(m => m.Tags)%>
            </p>

<%--            <p>
                <%: Html.LabelFor(m => Model.Country) %>
                <%: Html.EditorFor(m => Model.Country)%>                
            </p>--%>
<%--
            <h3>Optional Info</h3>
            --%>

            <%--
            <p>
                <%: Html.LabelFor(m => Model.ContactPhone) %>
                <%: Html.EditorFor(m => Model.ContactPhone)%>
            </p>--%>
            <p>
            
                <%: Html.HiddenFor(m => m.EventDate)%>
                <%: Html.HiddenFor(m => m.TimeCreated)%>
                <%: Html.HiddenFor(m => m.Latitude)%>
                <%: Html.HiddenFor(m => m.Longitude)%>
            </p>     
            <p>
                <input type="submit" value="Save" class="button"/>
            </p>
            </div>
        </div>



        <div id="mapDiv">
        
        <div class="widget">
            <%: Html.EditorFor(m => m.Location) %>
            </div>
        </div>
    </fieldset>
    <% } %>
    <script type="text/javascript">
//<![CDATA[
        $(document).ready(function () {
            Ditto.EnableMapMouseClickCallback();

            $("#Address").blur(function (evt) {
                //If it's time to look for an address, 
                // clear out the Lat and Lon
                $("#Latitude").val("0");
                $("#Longitude").val("0");
                var address = jQuery.trim($("#Address").val());
                if (address.length < 1)
                    return;
                Ditto.FindAddressOnMap(address);
            });
            Ditto.FindAddressOnMap("<%: Model.Location.Address %>");
        });
//]]>
    </script>
</asp:Content>
